#!/usr/bin/env python
# -*- coding: utf-8 -*-
# 时间     : 2020/07/29 21:02
# 作者     : DL (584054432@qq.com)
# 网址     : https://gitee.com/dingliangPython/
# 软件版本 : Python3.7.3
# 功能     ：

import wmi

c = wmi.WMI()


def get_device_serial_number():
    device_dict = {}
    # CPU序列号
    device_dict['cpu'] = [str(cpu.ProcessorId).strip() for cpu in c.Win32_Processor()]
    # print("CPU序列号",cpu.ProcessorId.strip())

    # # 硬盘序列号
    device_dict['disk'] = [str(physical_disk.SerialNumber).strip() for physical_disk in c.Win32_DiskDrive()]
    # print("硬盘序列号",physical_disk.SerialNumber)

    # 主板序列号
    device_dict['motherboard'] = [str(board_id.SerialNumber).strip() for board_id in c.Win32_BaseBoard()]
    # print("主板序列号",board_id.SerialNumber)

    # mac地址
    device_dict['mac'] = [str(mac.MACAddress.strip()) for mac in c.Win32_NetworkAdapter() if mac.MACAddress]
    # print("mac地址",mac.MACAddress)

    # bios序列号
    device_dict['bios'] = [str(bios_id.SerialNumber).strip() for bios_id in c.Win32_BIOS()]
    # print("bios序列号",bios_id.SerialNumber.strip())
    return device_dict


if __name__ == '__main__':
    print(get_device_serial_number())